<template>
  <div class="container">
    <div class="content">
      <div class="temp1">
        <div class="top">
          <h3>你好 我是AI ViviPlay</h3>
          <p>基于LLM模型的I角色扮演,开创更新的未来,成全你的梦想</p>
        </div>
        <div class="middle">
          <div class="message-item">
            <img src="@/assets/images/roles.jpg" alt="AI头像" class="avatar" />
            测试AI角色1
          </div>
          <div class="message-item user">
            测试用户提问2
            <img src="@/assets/images/roles.jpg" alt="用户头像" class="avatar" style="margin-left: auto;"/>
          </div>
        </div>
        <div class="bottom">
          <div class="voice-button">
            <el-button
              class="voice-icon"
              circle
              icon="Microphone"
              :class="{ recording: isRecording }"
              @click="isRecording = !isRecording"
            />
            <div class="voice-placeholder">
              {{
                isRecording
                  ? "正在录音...点击结束"
                  : "点击麦克风图标，即可进行语音输入，畅快和我交流"
              }}
            </div>
            <el-button class="send-btn" type="primary" size="small">
              发送
            </el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
const isRecording = ref(false);
</script>

<style scoped>
.container {
  width: 70%;
  margin: 0 auto;
  background-color: #f8f9fa;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  height: 80vh;
  overflow: hidden;
}

.content {
  height: 100%;
  padding: 0;
  position: relative;
}

.top {
  box-sizing: border-box;
  height: 90px;
  width: 100%;
  padding: 15px;
  background: linear-gradient(to right, #87ceeb, #a285dd);
  border-radius: 6px 6px 0 0;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
}

.top h3 {
  line-height: 36px;
  font-weight: 500;
  font-size: 25px;
  margin: 0;
  color: white;
}

.top p {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
}

.middle {
  position: absolute;
  top: 90px;
  bottom: 64px;
  width: 100%;
  overflow-y: auto;
  padding: 20px;
  box-sizing: border-box;
}

.message-item {
  max-width: 50%;
  padding: 10px 15px;
  margin-bottom: 10px;
  border-radius: 8px;
  background-color: #e9f5ff;
  align-self: flex-start;
  display: flex;
  align-items: flex-start;
}

.message-item.user {
  margin-left: auto;
  background-color: #dcfce7;
  display: flex;
  align-items: flex-start;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-right: 10px;
}

.message-item.user .avatar {
  margin-right: 0;
  margin-left: 10px;
}

.bottom {
  height: 64px;
  width: 100%;
  padding: 8px;
  box-sizing: border-box;
  position: absolute;
  bottom: 10px;
  left: 0;
  z-index: 10;
  background-color: #f8f9fa;
  border-top: 1px solid #e5e7eb;
}

.voice-button {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 6px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-sizing: border-box;
  background-color: #fff;
  height: 100%;
}

.voice-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(to right, #87CEEB, #a285dd);
  border: none;
  margin-right: 12px;
  transition: all 0.3s ease;
}

.voice-icon.recording {
  background: linear-gradient(to right, #ff6b6b, #ff8e8e);
  animation: pulse 1.5s infinite;
}

.voice-placeholder {
  flex: 1;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.5;
  padding: 8px 0;
}

.send-btn {
  margin-left: 12px;
  min-width: 80px;
  background: linear-gradient(to right, #87CEEB, #a285dd);
  border: none;
  transition: all 0.2s;
}

.send-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.middle::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.middle::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.middle::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
  transition: background 0.2s;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(255, 107, 107, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0);
  }
}
</style>